package com.lyz.dataStructure.javaDataStructure.shunxubiao;/**
 * @Author:759057893@qq.com Lyz
 * @Date: ${Date} 14:09
 * @Description:
 **/

/**
 *@Author:759057893@qq.com Lyz
 *@Date: 2019/8/16 14:09
 *@Description:
 **/
public class SqList {
    private Object[] listElem;
    private int curLen;

    public SqList(int maxSize){
        curLen = 0;
        listElem = new Object[maxSize];
    }

    public void insert(int i,Object x) throws Exception {
        if(curLen==listElem.length){
            throw new Exception("顺序表已满");
        }
        if(i<0||i>curLen){
            throw new Exception("插入的顺序不对");
        }
        for(int j =curLen;j>i;j--){
            listElem[j] = listElem[j-1];
        }
        listElem[i] = x;
        curLen++;
    }
}
